@extends('admin.common.main')
   
@section('cnt')
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a><cite>房源属性列表</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form action="{{ route('admin.fangattr.index') }}" method="get" class="layui-form layui-col-md12 x-so">
                <input type="text" name="name" placeholder="请输入节点名称" autocomplete="off" class="layui-input" value="">
                <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
        </div>
        <xblock>
            <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
            <button class="layui-btn" onclick="x_admin_show('添加节点','{{route("admin.fangattr.create")}}')"><i class="layui-icon"></i>添加房源属性</button>
            <span class="x-right" style="line-height:40px">共有数据：88 条</span>
        </xblock>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>
                        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                    </th>
                    <th>ID</th>
                    <th>房源属性名称</th>
                    <th>图标</th>
                    <th>字段名称</th>
                    <th>加入时间</th>
                    <th>操作</th>
            </thead>
            <tbody>
                @foreach($data as $item)
                <tr>
                    <td>
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{{ $item['id'] }}'><i class="layui-icon">&#xe605;</i></div>
                    </td>
                    <td>{{ $item['id'] }}</td>
                    <td>
                        {{ $item['html'] }}
                        {{ $item['name'] }}
                    </td>
                    <td><img src="{{ $item['icon'] }}"></td>
                    <td>
                        {{ $item['field_name'] }}
                    </td>
                    <td>{{ $item['created_at'] }}</td>
                    <td class="td-manage">
                         <a title="编辑" onclick="x_admin_show('编辑','{{ route("admin.fangattr.edit",['id'=>$item['id']]) }}')" href="javascript:;">
                                <i class="layui-icon">修改</i>
                            </a>
                        <a title="删除" class="del" data-href="{{ route("admin.fangattr.destroy",["id"=>$item['id']]) }}" href="javascript:;">
                            删除
                        </a>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
@endsection

@section('js')
<script>
  $(".del").click(function(){
        let _that = $(this);
        let url = _that.attr('data-href');
        const _token = "{{ csrf_token() }}";
        layer.confirm('确认要删除吗?',function(index){
            $.ajax({
                url,
                type:'DELETE',
                data:{
                    _token
                }
            }).then(ret=>{
                if(ret.status == 0){
                    layer.msg(ret.msg,{icon:1,time:500},function(){
                        _that.parents('tr').remove();
                    });
                }
            });
        });
    });
    </script>
@endsection